<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <h1>{{title}}</h1>
        <my-Head></my-Head>
        <my-foot></my-foot>
        <my-div></my-div>
        <First></First>
        <m-menu></m-menu>
        <div id="list">
            <p>这是原有的p标签</p>
        </div>

        <new-list></new-list>
        <f-div></f-div>
        <btn></btn>
        <btn></btn>
        <btn></btn>
    </div>
</body>
<script>
    // 全局注册 组件模板
    Vue.component("myHead", {
        template: "<header>Head--自定义的头部组件 </header>"
    })

    Vue.component("my-foot", {
        template: "<footer>footer--自定义的尾部footer组件 </footer>"
    })

    Vue.component("First", {
        template: "<div><p>are you ok?</p>  <span>I am not good</span></div>"
    })

    const menu = {
        template: "<h5>菜单栏目--菜单栏目</h5> "
    }

    Vue.component("mMenu", menu)

    const list = Vue.extend({ /* 子组件 */
        template: "<div>List---this a list</div>"
    })
    new list().$mount("#list")

    Vue.component("newList", list)


    Vue.component("fDiv", {
        template: "<div>我就试试</div>"
    })

    Vue.component("btn", {
        template: "<button @click='changeCount'>{{count}}</button>",
        data() {
            return {
                count: 0
            }
        },
        mounnted() {
            console.log("button init");
        },
        methods: {
            changeCount() {
                this.count++
            }
        }
    })


    const vm = new Vue({
        // 局部组件注册
        components: {
            myDiv: {
                template: "<div>div--局部注册自定义div组件</div>"
            }
        },
        data: {
            title: "Vue 组件初始化",

        },

    }).$mount("#app")
</script>

</html>